/*
 * @Author: szx
 * @Date: 2021-12-11 13:39:27
 * @LastEditTime: 2021-12-11 13:46:59
 * @Description:
 * @FilePath: \leetcode\1-99\20\20.js
 */
/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function (s) {
    let st = [];
    for (let ch of s) {
        if (ch == '(') st.push(')');
        else if (ch == '[') st.push(']');
        else if (ch == '{') st.push('}');
        else if (st.length == 0 || st[st.length - 1] != ch) return false;
        else st.pop();
    }
    return st.length == 0;
};
